package com.gege.hmily.account.controller;

import com.gege.hmily.account.service.AccountService;
import com.gege.hmily.api.AccountApi;
import com.gege.hmily.request.PayRequest;
import com.gege.hmily.response.BaseResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author gechenpeng
 * @date 2021-05-28
 */
@RestController
public class AccountController implements AccountApi {

    private final AccountService accountService;

    @Autowired(required = false)
    public AccountController(AccountService accountService) {
        this.accountService = accountService;
    }

    @Override
    public BaseResponse pay(@RequestBody PayRequest payRequest) {
        accountService.pay(payRequest.getUserId(), payRequest.getAmount());
        return BaseResponse.ok();
    }
}
